#include "stdafx.h"
#include "FileHelper.h"

bool inline isWhiteSpace(char ch)
{
	if(ch ==' ' || ch == '/t' || ch == 9)
		return true;
	else
		return false;
}

string& trim(string& str)
{
	while(str.length() >0 && isWhiteSpace(str.at(0)))
		str.erase(0,1);
	while(str.length() >0 && isWhiteSpace(*(str.rbegin())))
		str.erase(str.length()-1,1);
	return str;
}

void Tokenize(const string& str,vector<string>& tokens,const string& delimiters)
{
	string::size_type lastPos = str.find_first_not_of(delimiters, 0);
	string::size_type pos     = str.find_first_of(delimiters, lastPos);

	while (string::npos != pos || string::npos != lastPos)
	{
		tokens.push_back(trim(str.substr(lastPos, pos - lastPos)));
		lastPos = str.find_first_not_of(delimiters, pos);
		pos = str.find_first_of(delimiters, lastPos);
	}
}